<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
	$(document).ready(function() {
		$("#editCipeprojectForm").validate({
			rules : {
				partner : {
					required : true
				},
				acronym : {
					required : true
				},
				costCenterNumber : {
					required : true
				},
				projectTitle : {
					required : true
				},
				donoraward : {
					required : true
				},
				projectStartDate : {
					required : true
				},
				projectEndDate : {
					required : true
				},
				cipeprojecttype : {
					required : true
				},
				cipeprojectstatus : {
					required : true
				},
				region : {
					required : true
				},
				country : {
					required : true
				},
				seniorProgramOfficer : {
					required : true
				},
				programOfficer : {
					required : true
				},
				programAssistant : {
					required : true
				},
				managementFunds : {
					required : true
				}
			}
		});
	});
	$(function() {
		$("#projectStartDate").datepicker();
	});

	$(function() {
		$("#projectEndDate").datepicker();
	});
	$('.add-partner-link').click(function() {
		loadDiv('content', 'showAddPartner.do');
	});
	$("#fiscalyear").datepicker({
		dateFormat : 'yy'
	});
	function getFiscalYear() {
		var str1 = document.getElementById("projectStartDate").value;

		var mon1 = parseInt(str1.substring(0, 2), 10);
		var dt1 = parseInt(str1.substring(3, 5), 10);
		var yr1 = parseInt(str1.substring(6, 10), 10);
		var dt2 = 1;
		var mon2 = 10;
		var date1 = new Date(yr1, mon1, dt1);
		var date2 = new Date(yr1, mon2, dt2);
		if (date2 < date1) {
			document.getElementById("fiscalyear").value = yr1;
		} else {
			document.getElementById("fiscalyear").value = parseInt(yr1) - 1;
		}
	}
</script>
<div id="editCipeprojectDiv">
	<form:form name="editCipeprojectForm" id="editCipeprojectForm" action="saveCipeproject.do" method="post" modelAttribute="cipeproject">
		<form:hidden path="id" />
		<table>
			<tr class="row">
				<td class="label">&nbsp;</td>
				<td class="input-field" colspan="2">
					<%@ include file="/common/messages.jsp" %>
				</td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.partner" /></td>
				<td class="input-field"><form:select path="partner.id" cssClass="input-full-width-req">
						<form:options items="${partnerList}" itemValue="id" itemLabel="partnerName" />
						</form:select> <a href="javascript://" class="add-partner-link"><spring:message code="link.add" /></a></td>
				<td><form:errors path="partner.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.acronym" /></td>
				<td class="input-field"><form:input path="acronym" cssClass="input-full-width-req" /></td>
				<td><form:errors path="acronym" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.costCenter" /></td>
				<td class="input-field"><form:input path="costCenterNumber" cssClass="input-full-width-req" /></td>
				<td><form:errors path="costCenterNumber" cssClass="error" /></td>
			</tr>
			<%--  
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.subIdentifier" /></td>
				<td class="input-field"><form:select path="cipeprojectrollup.id">
						<form:options items="${subidentifierList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="cipeprojectrollup.id" cssClass="error" /></td>
			</tr>
			 --%>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.projectID" /></td>
				<td class="input-field"><form:input path="projectID" cssClass="input-full-width" /></td>
				<td><form:errors path="projectID" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.projectTitle" /></td>
				<td class="input-field"><form:input path="projectTitle" cssClass="input-full-width-req" /></td>
				<td><form:errors path="projectTitle" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.nedIdentifier" /></td>
				<td class="input-field"><form:input path="nedIdentifier" cssClass="input-full-width" /></td>
				<td><form:errors path="nedIdentifier" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.donorAwardID" /></td>
				<td class="input-field"><form:select path="donoraward.id" cssClass="input-full-width-req">
						<form:options items="${donorawardList}" itemValue="id" itemLabel="donorAwardNumber" />
					</form:select></td>
				<td><form:errors path="donoraward.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.donorName" /></td>
				<td class="input-field"><form:input path="" disabled="true" cssClass="input-full-width" /></td>
				<td><form:errors path="" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.donorStartDate" /></td>
				<td class="input-field"><form:input path="" disabled="true" cssClass="input-full-width" /></td>
				<td><form:errors path="" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.donorEndDate" /></td>
				<td class="input-field"><form:input path="" disabled="true" cssClass="input-full-width" /></td>
				<td><form:errors path="" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.startDate" /></td>
				<td class="input-field"><form:input path="projectStartDate" cssClass="input-full-width-req" onchange="getFiscalYear()" /></td>
				<td><form:errors path="projectStartDate" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.endDate" /></td>
				<td class="input-field"><form:input path="projectEndDate" cssClass="input-full-width-req" /></td>
				<td><form:errors path="projectEndDate" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.type" /></td>
				<td class="input-field"><form:select path="cipeprojecttype.id" cssClass="input-full-width-req">
						<form:options items="${cipeprojecttypeList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="cipeprojecttype.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.status" /></td>
				<td class="input-field"><form:select path="cipeprojectstatus.id" cssClass="input-full-width-req">
						<form:options items="${cipeprojectstatusList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="cipeprojecttype.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.region" /></td>
				<td class="input-field"><form:select path="region.id" cssClass="input-full-width-req">
						<form:options items="${regionList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="region.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.country" /></td>
				<td class="input-field"><form:select path="country.id" cssClass="input-full-width-req">
						<form:options items="${countryList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="country.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.seniorProgramOfficer" /></td>
				<td class="input-field"><form:select path="seniorProgramOfficer.id" cssClass="input-full-width-req">
						<form:options items="${seniorProgramOfficerList}" itemValue="id" itemLabel="fullName" />
					</form:select></td>
				<td><form:errors path="seniorProgramOfficer.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.programOfficer" /></td>
				<td class="input-field"><form:select path="programOfficer.id" cssClass="input-full-width-req">
						<form:options items="${programOfficerList}" itemValue="id" itemLabel="fullName" />
					</form:select></td>
				<td><form:errors path="programOfficer.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.programAssistant" /></td>
				<td class="input-field"><form:select path="programAssistant.id" cssClass="input-full-width-req">
						<form:options items="${programAssistantList}" itemValue="id" itemLabel="fullName" />
					</form:select></td>
				<td><form:errors path="programAssistant.id" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.managementFunds" /></td>
				<td class="input-field"><form:input path="managementFunds" cssClass="input-full-width-req" /></td>
				<td><form:errors path="managementFunds" cssClass="error" /></td>
			</tr>
			<%--
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.rollup" /></td>
				<td class="input-field"><form:select path="cipeprojectrollup.id">
						<form:options items="${cipeprojectrollupList}" itemValue="id" itemLabel="displayName" />
					</form:select></td>
				<td><form:errors path="cipeprojectrollup.id" cssClass="error" /></td>
			</tr>
			 --%>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.fiscalYear" /></td>
				<td class="input-field"><form:input path="fiscalYear" cssClass="input-full-width" /></td>
				<td><form:errors path="fiscalYear" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.memo" /></td>
				<td class="input-field"><form:input path="memo" cssClass="input-full-width" /></td>
				<td><form:errors path="memo" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.fileLocation" /></td>
				<td class="input-field"><form:input path="fileLocation" cssClass="input-full-width" /></td>
				<td><form:errors path="fileLocation" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="label.createdBy" /></td>
				<td class="input-field"><form:input disabled="true" path="createdBy.fullName" cssClass="input-full-width" /></td>
				<td><form:errors path="createdBy" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="label.creationDate" /></td>
				<td class="input-field"><form:input disabled="true" path="creationDate" cssClass="input-full-width" /></td>
				<td><form:errors path="creationDate" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="label.updatedBy" /></td>
				<td class="input-field"><form:input disabled="true" path="updatedBy.fullName" cssClass="input-full-width" /></td>
				<td><form:errors path="updatedBy" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="label.updationDate" /></td>
				<td class="input-field"><form:input disabled="true" path="updationDate" cssClass="input-full-width" /></td>
				<td><form:errors path="updationDate" cssClass="error" /></td>
			</tr>
			<!--  <tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.accountingQuestionnaire" /></td>
				<td class="input-field"><form:checkbox path="accountingQuestionnaireReceived" cssClass="input-full-width" value="true" /></td>
				<td><form:errors path="accountingQuestionnaireReceived" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.checkPerformed" /></td>
				<td class="input-field"><form:checkbox path="terroristCheckPerformed" cssClass="input-full-width" value="true" /></td>
				<td><form:errors path="terroristCheckPerformed" cssClass="error" /></td>
			</tr>-->
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.blockTimeSheet" /></td>
				<td class="input-field"><form:checkbox path="blockTimeSheet" cssClass="input-full-width" value="true" /></td>
				<td><form:errors path="blockTimeSheet" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label"><spring:message code="editCipeproject.label.override" /></td>
				<td class="input-field"><form:checkbox path="override" cssClass="input-full-width" value="true" /></td>
				<td><form:errors path="override" cssClass="error" /></td>
			</tr>
			<tr class="row">
				<td class="label">&nbsp;</td>
				<td class="input-field"><sj:submit id="loginFormSubmit" target="editCipeprojectDiv" key="editCipeproject.button.save" validate="true" /> <input type="reset" value="<spring:message code='editCipeproject.button.cancel' />" /></td>
				<td>&nbsp;</td>
			</tr>
		</table>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function() {
			$('table.tablesorter').tablesorter({
				widgets : [ 'zebra' ],
				sortList : [ [ 0, 0 ] ],
				headers : {
					3 : {
						sorter : false
					},
					4 : {
						sorter : false
					}
				}
			});

			$('.edit-cipeprojectaward-link').click(function() {
				loadDiv('content', 'showEditCipeprojectaward.do?id=' + $(this).attr('cipeprojectawardId'));
			});
		});
	</script>
	<div id="cipeprojectawardListDiv" class="hastable">
		<%-- <table class="tablesorter">
		<thead>
			<tr>
				<th><spring:message code="cipeprojectawardlist.table.heading.cipeprojectAwardNumber"/></th>
				<th><spring:message code="cipeprojectawardlist.table.heading.cipeprojectAwardDesc"/></th>
				<th><spring:message code="cipeprojectawardlist.table.heading.startDate"/></th>
				<th><spring:message code="cipeprojectawardlist.table.heading.city"/></th>
				<th><spring:message code="cipeprojectawardlist.table.heading.state"/></th>							
				<th><spring:message code="cipeprojectawardlist.table.heading.viewAward"/></th>
				<th><spring:message code="cipeprojectawardlist.table.heading.edit"/></th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${cipeproject.cipeprojectawards}" var="cipeprojectaward">
				<tr>
					<td>${cipeprojectaward.cipeprojectAwardNumber}</td>
					<td>${cipeprojectaward.cipeprojectAwardDesc}</td>
					<td>${cipeprojectaward.startDate}</td>
					<td>${cipeprojectaward.city}</td>
					<td>${cipeprojectaward.state}</td>				
					<td><a href="javascript://" class="view-awards-link" cipeprojectawardId="${cipeprojectaward.id}"><spring:message code="cipeprojectawardlist.table.link.viewAward"/></a></td>
					<td><a href="javascript://" class="edit-cipeprojectaward-link" cipeprojectawardId="${cipeprojectaward.id}"><spring:message code="cipeprojectawardlist.table.link.edit"/></a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table> --%>
		<div id="cipeprojectawardListPager"></div>
	</div>
	<table>
		<tr>
			<td></td>
		</tr>
		<tr>
			<td></td>
		</tr>
	</table>
</div>